package org.hhchat.others.toutiao.p2017;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created by HMH on 2017/3/30.
 */
public class toutiao01 {


    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int numbers[] = new int[n];
        for(int i=0;i<n;i++) {
            numbers[i] = scanner.nextInt();
        }


        List<Integer> up = new ArrayList<>();
        List<Integer> down = new ArrayList<>();
        for(int i=0;i<n;i++) {
            if(i == 0 && (numbers[i]>numbers[i+1])){
                up.add(i);
                continue;
            }
            else if(i==0){
                down.add(i);
                continue;
            }
            if(i == n-1 && (numbers[i]>numbers[i-1])){
                up.add(i);
                break;
            } else if (i == n - 1) {
                down.add(i);
                break;
            }
            if (numbers[i] > numbers[i - 1] && numbers[i] > numbers[i + 1]) {
                up.add(i);
            }else if(numbers[i]<numbers[i-1] && numbers[i]<numbers[ i+1 ]){
                down.add(i);
            }
        }
        int start = -1;
        boolean isup=false;
        List<Integer> points = new ArrayList<>();
        int top = -1;
        int end=-1;
        int width=0;
        if(down.size()<2) {
            System.out.println("-1 -1");
            return;
        }
        for(int i=0;i<down.size()-1;i++) {
            if (down.get(i + 1) - down.get(i) + 1 > width) {
                width = down.get(i + 1) - down.get(i) + 1;
                start = down.get(i);
                end = down.get(i + 1);
            }
        }
        System.out.println(start+" "+end);
    }
}
